<script type="text/javascript">
                //验证码
                function getVcode_portal(){
                    $.ajax({
                        url:"http://yun.zjer.cn/index.php?r=portal/Vcode/GetNewCode",
                        type:'get',
                        data:{},
                        dataType:'jsonp',
                        callback:'VailCode',
                        beforeSend:function(){
                            $('#click_vail_portal').hide();
                            $('#cimage_portal').hide();
                            $('#vail_loadding_portal').show();
                        },
                        success:function(json){
                            if(json){
                                $('#cimage_portal').attr('src',json.imageinfo);
                                $('#cimage_portal').attr('vaildata',json.passCode);
                                $("#valCode1").removeAttr('readonly');
                                $('#vail_loadding_portal').hide();
                                $('#cimage_portal').show();
                            }
                            else{
                                //art.tips({content:'网络错误',type:2});
                                $('#click_vail_portal').show();
                                $('#vail_loadding_portal').hide();
                            }
                        },
                        error:function(){
                            //art.tips({content:'网络错误',type:2});
                            $('#click_vail_portal').show();
                            $('#vail_loadding_portal').hide();
                        }
                    });
                }
                //登录处理
                $('#loginyc').live("click",function(){
                    var userId = $('#info_username-1').val();
                    var userPsw = $('#info_password-1').val();
                    var remember = $('#remember').val();
                    var submit_url = $('#loginForm-1').attr('data-url');
                    var vaildata = $('#cimage_portal').attr('vaildata');
                    var valCode = $('#valCode1').val();
                    userId = encode_string(userId);
                    userPsw = encode_string(userPsw);
                    if($.trim(valCode) == '') {
                        $('#login-erro').html('请输入验证码').parent().show();return false;
                    }
                    if($(this).attr('disabled') == 'disabled') return false;
                    $(this).attr('disabled','disabled');
                    //ajax调用
                    $.ajax({
                        type:"POST",
                        timeout:10000,
                        dataType:"jsonp",
                        cache:false,
                        url:submit_url,
                        callback:'portal_login',
                        data:{
                            userId:userId,
                            userPsw:userPsw,
                            remember:remember,
                            vaildata:vaildata,
                            valCode:valCode,
                            encrypt:'encrypt'
                        },
                        success: function(data){
                            if(data){
                                if(data.code!='000000'){
                                    $('#login-erro').html(''+data.message+'').parent().show();
                                    $('#valCode1').parent().show();
                                    $('#cimage_portal').click();
                                    $('#loginyc').attr('disabled',false);
                                    $('#valCode1').val('');
                                    return false;
                                }else{
                                    $('#loginyc').val("登录成功");
                                    if(data.addpoint=='000000'){
                                        $('#loginForm-1 .err-tips').html('&nbsp;&nbsp;登录成功,增加2积分和2经验值').show();
                                    }else{
                                        $('#loginForm-1 .err-tips').html('&nbsp;&nbsp;登录成功 正在跳转中···').show();
                                    }
                                    //window.parent.location.href = "//";
                                    /*R.J.M add 2016-2-18 为了让身份证激活学生用户登录后直接进空间，故添加此项*/
                                    var re1= /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/;
                                    var re2 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
                                    var ac = $('#info_username-1').val().replace(/(^\s*)|(\s*$)/g, "");
                                    window.usertype = data.usertype;
                                    var account = userId;
                                    var pwd = userPsw;
                                    if(usertype == '0' && re1.test(ac) || re2.test(ac) && usertype == '0'){
                                        //平台联合登录-开始
                                        var url = "/index.php?r=portal/index/index";
                                        uc_login(account,pwd,url,data.platformCode,data.ppd);
                                        //平台联合登录-结束
                                    }
                                    else{
                                        //平台联合登录-开始
                                        var url = "/index.php?r=portal/index/index";
                                        uc_login(account,pwd,url,data.platformCode,data.ppd);
                                        //平台联合登录-结束
                                    }
                                    //window.parent.location.href = "/index.php?r=portal/index/index";
                                }

                            }
                        },
                        error:function(XMLHttpRequest, textStatus, errorThrown){
                            $('#loginyc').attr('disabled',false);
                            $('#info_username').focus();
                            $('#loginyc').val("登录");
                            if(textStatus == 'timeout'){
                                $('#login-erro').html('当前网络连接不可用！');
                            }
                            else{
                                $('#login-erro').html('当前网络连接不可用！');
                            }
                            return false;
                        }
                    });
                    return false;
                });
                //平台联合登录
                function uc_login(account,pwd,url,platformCode,pd) {
                    //用户平台
                    $.ajax({type:'GET',timeout:10000, dataType:'jsonp', cache:false, async:false, url:'http://yun.zjer.cn/index.php?r=uc/site', data:{platformCode:platformCode},
                        success: function(data){
                            if(data){
                                var n = data.length;
                                for(var i=0; i<data.length; i++){
                                    var site_domain = data[i].domain;
                                    $.ajax({type:'GET', dataType:'jsonp', cache:false, url:'http://'+site_domain+'/index.php?r=uc/login', data:{account:account, pd:pd, encrypt:'encrypt'},
                                        success: function(jsonp){
                                            n = n - 1;
                                            if (n == 0){
                                                window.parent.location.href = url;
                                            }
                                        },
                                        error: function(){
                                            n = n - 1;
                                            if (n == 0){
                                                window.parent.location.href = url;
                                            }
                                        }
                                    });
                                }
                            }else{
                                window.parent.location.href = url;
                            }
                        },
                        error:function(){
                            window.parent.location.href = url;
                        }
                    });
                }
                //平台联合注销
                $('.xy_loginbox a.tcbtn').live("click",function(){
                    var platformCode = '';
                    var $this = $(this);
                    var href = $this.attr('href');
                    $this.attr('href', 'javascript:;');
                    $.ajax({type:'GET', dataType:'jsonp', cache:false, async:false, url:'http://yun.zjer.cn/index.php?r=portal/user/logout', data:{platformCode:platformCode},
                    success: function(data){

                    }});
                    //用户平台
                    $.ajax({type:'GET', dataType:'jsonp', cache:false, async:false, url:'http://yun.zjer.cn/index.php?r=uc/site', data:{platformCode:platformCode},
                        success: function(data){
                            if(data){
                                var n = data.length;
                                for(var i=0; i<data.length; i++){
                                    var site_domain = data[i].domain;
                                    $.ajax({type:'GET', dataType:'jsonp', cache:false, url:'http://'+site_domain+'/index.php?r=uc/logout',
                                        success: function(jsonp){
                                            n = n - 1;
                                            if (n == 0){
                                                window.parent.location.href = href;
                                            }
                                        },
                                        error: function(){
                                            n = n - 1;
                                            if (n == 0){
                                                window.parent.location.href = href;
                                            }
                                        }
                                    });
                                }
                            }else{
                                window.parent.location.href = href;
                            }
                        }
                    });
                    return false;
                });
                //二维码登录处理
                function getQRcode(times){
                    $('#qr_div').hide();
                    var opts = {
                    length: 0 // The length of each line
                    , width: 5 // The line thickness
                    , radius: 30 // The radius of the inner circle
                    , color: '#ffffff' // #rgb or #rrggbb or array of colors
                    , top: '55%' // Top position relative to parent
                    , left: '50%' // Left position relative to parent
                    , shadow: true // Whether to render a shadow
                    , position: 'absolute' // Element positioning
                    };

                    $.ajax({
                        url:'http://yun.zjer.cn/index.php?r=api/QRcode/GetQRcontent',
                type: "GET",
                dataType: 'jsonp',
                jsonp: 'callback',
                jsonpCallback:'success_QRcode',
                        beforeSend:function(){
                            var target = document.getElementById('loadding')
                            window.spinner = new Spinner(opts).spin(target);
                        },
                        complete:function(){
                            window.spinner.stop();
                        },
                        success:function(json){
                            $('#portal_qrcode').empty();
                            //jQuery('#portal_qrcode').qrcode(json);
                            //new QRCode(document.getElementById("portal_qrcode"), {text:json,correctLevel:QRCode.CorrectLevel.H});
                            var qrcode = new QRCode(document.getElementById("portal_qrcode"), {
                                text: json.text,
                                width: 125,
                                height: 125,
                                typeNumber : 4,
                                colorDark : "#000000",
                                colorLight : "#ffffff",
                                correctLevel : QRCode.CorrectLevel.L
                            });
                            qrcode.clear();
                            qrcode.makeCode(json.text);
                            $('#qr_div').show();
                            $('#qr_token').val(json.token);
                            $('.sm-invalid').hide();
                            $('.sm-case').show();
                            getStatus();
                        },
                        error:function(){
                            $('.sm-case').hide();
                            $('.sm-invalid').show();
                            if(times < 5){
                                times += 1;
                                setTimeout('getQRcode('+times+');',1000);
                            }
                        }
                    });
                }
                $('#logoCaseTab').click(function(){
                    //避免冲突，延迟执行
                    setTimeout(function(){
                        if($('#logoCaseTab').attr('class') == 'logoCaseTab CaseTab2'){
                            getQRcode();
                        }
                        else{
                            QR_cancel();
                        }
                    },5);
                });
                $('#reload_qrcode').click(function(){
                    QR_cancel();
                    getQRcode();
                });
                $('#reload_qrcode1').click(function(){
                    QR_cancel();
                    $('.logoTips').children('span').html('扫码登录更安全');
                    $('.sm-finish').hide();
                });
                //获取当前二维码扫码进度
                function getStatus(){
                  var token = $('#qr_token').val();
                  var L_status = $('#qr_status').val();
                  $.ajax({
                    url:"http://yun.zjer.cn/index.php?r=api/QRcode/GetStatus&token="+token+'&L_status='+L_status,
                type: "GET",
                dataType: 'jsonp',
                jsonp: 'callback',
                jsonpCallback:'success_Status',
                    success:function(json){
                      if(json == null){
                        getStatus();
                      }
                      else{
                            $('#qr_status').val(json.code);
                            if(json.code == 99 ){
                                getStatus();
                            }
                            if(json.code == 1){
                                $('.smLoing-rect').hide();
                                $('.sm-finish').show();
                                    getStatus();
                            }
                            else if(json.code == 3){
                                //getQRcode();
                                if($('#logoCaseTab').attr('class') == 'logoCaseTab CaseTab2'){
                                  $('.smLoing-rect').hide();
                                  $('.passWord-case').show();
                                  $('#logoCaseTab').removeClass('CaseTab2');
                                }
                                $('.logoTips').children('span').html('扫码登录更安全');
                                $('.sm-finish').hide();
                            }
                            else if(json.code == 2){
                                $('#QRinfo1').html('用户已确认');
                                $('#QRinfo2').html('正在登录...');
                                $('#reload_qrcode1').remove();
                                $.ajax({
                                  url:'http://yun.zjer.cn/index.php?r=api/QRcode/Login&token='+token,
                                type: "GET",
                                dataType: 'jsonp',
                                jsonp: 'callback',
                                jsonpCallback:'success_login',
                                  success:function(json){
                                    if(json.code == '000000'){

                                        if(json.account && json.ccd){
                                            //用户平台
                                            $.ajax({type:'GET', dataType:'jsonp', cache:false, async:false, url:'http://yun.zjer.cn/index.php?r=uc/site', data:{platformCode:json.platfromcode},
                                                success: function(data){
                                                    if(data){
                                                        var n = data.length;
                                                        for(var i=0; i<data.length; i++){
                                                            var site_domain = data[i].domain;
                                                            $.ajax({type:'GET', dataType:'jsonp', cache:false, url:'http://'+site_domain+'/index.php?r=uc/login', data:{account:json.account, ccd:json.ccd,remember:0},
                                                                success: function(jsonp){
                                                                    n = n - 1;
                                                                    if (n == 0){
                                                                        //window.parent.location.href = url;
                                                                        //redirect_url('timeout');
                                                                        $('#QRinfo2').html('登录成功，正在跳转...');
                                    redirect_url('timeout');
                                                                    }
                                                                },
                                                                error: function(){
                                                                    n = n - 1;
                                                                    if (n == 0){
                                                                        //window.parent.location.href = url;
                                                                        //redirect_url('timeout');
                                                                        $('#QRinfo2').html('登录成功，正在跳转...');
                                    redirect_url('timeout');
                                                                    }
                                                                }
                                                            });
                                                        }
                                                    }else{
                                                        //window.parent.location.href = url;
                                                        //redirect_url('timeout');
                                                        $('#QRinfo2').html('登录成功，正在跳转...');
                                    redirect_url('timeout');
                                                    }
                                                },
                                                error:function(){
                                                    //redirect_url('timeout');
                                                    $('#QRinfo2').html('登录成功，正在跳转...');
                                    redirect_url('timeout');
                                                }
                                            });

                                        }
                                        else{
                                            $('#QRinfo2').html('登录成功，正在跳转...');
                                    redirect_url('timeout');
                                        }

                                        //$('#QRinfo2').html('登录成功，正在跳转...');
                                    }
                                    else{
                                        $('#QRinfo2').html(json.msg);
                                    }
                                    //setTimeout('window.location.reload();',500);
                                  }
                                });
                            }
                            else if(json.code == 6){
                                $('.sm-finish').hide();
                                $('.smLoing-rect').show();
                                $('.sm-case').hide();
                                $('.sm-invalid').show();
                            }
                      }
                    }
                  });
                }

                function QR_cancel(){
                    var token = $('#qr_token').val();
            $.getJSON("http://yun.zjer.cn/index.php?r=api/QRcode/cancel&token="+token+'&jsoncallback=?');
                }

                //登录跳转
        function redirect_url(param){
            var url = '';
            var skipurl = '';
            var skip = $.trim($('#userAction').val());
            if(skip == 'UserSet'){
                var currentHost = 'http://'+window.location.host;
                if(currentHost.indexOf('http://yun.zjer.cn') !== -1 ){
                    //测试要求连接(r=portal/usecount/anindex)登录成功后，不要跳转到个人中心，所以增加下面的if条件，详见jira(EDUZJTHREE-7394)
                    if(location.href.indexOf('r=portal/usecount/anindex') === -1){

                        $.ajax({
                            url:'http://yun.zjer.cn/index.php?r=portal/user/AjaxRedirectJson',
                            async:false,dataType:'json',
                            success:function(data){
                                url = data.url;
                            }
                        });
                        if(url){
                            skipurl =  url;
                        }
                        else{
                            skipurl = window.location.href;
                        }

                    }

                }
                else{
                    skipurl = window.location.href;
                }
            }
            else if(skip){
                skipurl = skip;
            }
            else{
                //skipurl = 'http://yun.zjer.cn/';
                skipurl = window.location.href;
            }
            var reg = /#/g;
            skipurl =  skipurl.replace(reg,'');;
            if(param == 'timeout'){
                setTimeout('window.location.href = "'+skipurl+'";',500);
            }
            else{
                window.location.href = skipurl;
            }
        }
        </script>